#ifndef __UART_H
#define __UART_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "system_remap.h"

typedef struct
{
  uint32_t UART_BaudRate;            /*!< This member configures the UART communication baud rate */

  uint16_t UART_WordLength;          /*!< Specifies the number of data bits transmitted or received in a frame.
                                           This parameter can be a value of @ref UART_Word_Length */
 
  uint16_t UART_Mode;                /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
                                           This parameter can be a value of @ref UART_Mode */

} UART_InitTypeDef;



/**
  * @}
  */ 


/** @defgroup UART_Word_Length 
  * @{
  */ 
  
#define UART_WordLength_8b                  ((uint16_t)0x0080)
#define UART_WordLength_9b                  ((uint16_t)0x0000)


/** @defgroup UART_Parity 
  * @{
  */ 
  
#define UART_Parity_No                      ((uint16_t)0x0000)
#define UART_Parity_Even                    ((uint16_t)0x0400)
#define UART_Parity_Odd                     ((uint16_t)0x0600) 


/** @defgroup UART_Mode 
  * @{
  */ 
  
#define UART_Mode_Tx_Rx                     ((uint16_t)0x0010)
#define UART_Mode_Tx                        ((uint16_t)0x0008)

/**
  * @}
  */ 

/** @defgroup UART_Interrupt_definition 
  * @{
  */
  
#define UART_IT_EN							      ((uint16_t)0x0040)
#define UART_IT_FLAG_TXC                          ((uint16_t)0x0002)
#define UART_IT_FLAG_RXC                          ((uint16_t)0x0001)

/**
  * @}
  */

/** @defgroup UART_DMA_Requests 
  * @{
  */

#define UART_DMAReq_Tx                      ((uint16_t)0x8000)
#define UART_DMAReq_Rx                      ((uint16_t)0x4000)


/**
  * @}
  */ 

/** @defgroup UART_Flags 
  * @{
  */

#define UART_FLAG_TC                        ((uint16_t)0x0002)
#define UART_FLAG_RXNE                      ((uint16_t)0x0001)

/**
  * @}
  */ 

/** @defgroup UART_Exported_Functions
  * @{
  */

void UART_DeInit(UART_TypeDef* UARTx);
void UART_Init(UART_TypeDef* UARTx, UART_InitTypeDef* UART_InitStruct);
void UART_StructInit(UART_InitTypeDef* UART_InitStruct);
void UART_Cmd(UART_TypeDef* UARTx, FunctionalState NewState);
void UART_ITConfig(UART_TypeDef* UARTx, uint16_t UART_IT, FunctionalState NewState);
void UART_DMACmd(UART_TypeDef* UARTx, uint16_t UART_DMAReq, FunctionalState NewState);
void UART_SendData(UART_TypeDef* UARTx, uint16_t Data);
uint16_t UART_ReceiveData(UART_TypeDef* UARTx);
FlagStatus UART_GetFlagStatus(UART_TypeDef* UARTx, uint16_t UART_FLAG);
void UART_ClearFlag(UART_TypeDef* UARTx, uint16_t UART_FLAG);
ITStatus UART_GetITStatus(UART_TypeDef* UARTx, uint16_t UART_IT);
void UART_ClearITPendingBit(UART_TypeDef* UARTx, uint16_t UART_IT);

#ifdef __cplusplus
}
#endif

#endif /* __UART_H */
